/* 
 * File:   mem.hpp
 * Author: gustavo
 *
 * Created on August 28, 2012, 2:16 AM
 */

#ifndef MEM_H
#define	MEM_H

//#include <stdlib.h>

#define mem_alloc_size(size) (void *) calloc( 1, (size) )
#define mem_alloc(type) (type *) calloc( 1, sizeof(type) )
#define mem_allocn(n, type) (type *) calloc( (n), sizeof(type) )
#define mem_free(p) { if(p) {free(p); p = 0;} }
#define mem_copy( src, dest, n ) ( mem_copy_function( (char*) src, (char*) dest, n*sizeof(*src) ) )
#define mem_clear( src, n) ( mem_clear_function( (char*) src, n*sizeof(*src) ) )

	void mem_copy_function(char * dest, char * src, int nbytes);
	void mem_clear_function(char * dest, int nbytes);


#endif	/* MEM_H */

